<?php
$orderConfigTable = new BPSheet('orderConfig');
$configList = array();
?>
<?php
$model = new BDynamicFormModel();
$modelClass = get_class($model);
$screen = Blyn::app()->getUIManager()->getCurrentScreen();
$url = $control->getAjaxLinkUrl('saveOnlineOrderConfig', NULL, array(
    'eventId' => $eventId,
    'configId' => $configId));
$updateId = $control->getAjaxContainerId();
?>

<?php
$form = $this->beginWidget('CActiveForm', array(
    "id" => "addOrderConfigForm",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('enctype' => 'multipart/form-data'),
        ));
?>
<link rel="stylesheet" type="text/css"
      href="<?php echo Yii::app()->request->baseUrl; ?>/css/bootstrap-datetimepicker.min.css" />
<script  type="text/javascript"
         src="<?php echo Yii::app()->request->baseUrl; ?>/js/bootstrap-datetimepicker.min.js"/>

<script type="text/javascript">
// this script for collecting the form data and pass to the controller action and doing the on success validations
    function savePriceConfig() {

        var formData = new FormData($("#addOrderConfigForm")[0]);
        $.ajax({
            url: '<?php echo $url; ?>',
            type: 'POST',
            data: formData,
            //datatype: 'json',
            // async: false,
            beforeSend: function() {
                $("#ajax-loaderdiv").show();
            },
            success: function(html) {
                // on success do some validation or refresh the content div to display the uploaded images 
                jQuery("#<?php echo $updateId; ?>").html(html);
            },
            complete: function() {
                $("#ajax-loaderdiv").hide();
            },
            error: function(data) {
                alert("There may a error on uploading. Try again later");
            },
            cache: false,
            contentType: false,
            processData: false
        });

        return false;
    }
</script>
<?php
$viewData = array();
$viewData['model'] = $model;
$viewData['form'] = $form;
if (isset($eventId)) {
    $viewData['eventId'] = $eventId;
}
if (isset($configId)) {
    $viewData['configId'] = $configId;
}
if (isset($newConfigId)) {
    $viewData['newConfigId'] = $newConfigId;
}
?>
<div class="tabbable tabs-right" style="margin-top: 0px;"> <!-- Only required for left/right tabs -->
    <ul class="nav nav-tabs" style="margin-bottom: 15px">
        <li class="active"><a href="#tab1" data-toggle="tab"><?php echo '基本设置'; ?></a></li>    
        <li class=""><a href="#tab2" data-toggle="tab"><?php echo '价格设置'; ?></a></li>
        <li class=""><a href="#tab4" data-toggle="tab"><?php echo '其他设置'; ?></a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="tab1" style="min-height: 270px">                
            <?php
            $control->renderView('orderConfig_add_info', $viewData);
            ?>  
        </div>  
        <div class="tab-pane" id="tab2" style="min-height: 270px">                
            <?php
            //$control1 = new BUIControl('showAdjustPrice');
            $control->renderView('orderConfig_add_priceConfig_list', $viewData);
            //$control1->render();
            ?>  
        </div>

        <div class="tab-pane" id="tab4" style="min-height: 270px">                
            <?php
            $control->renderView('orderConfig_add_other', $viewData);
            ?>  
        </div>
    </div>
</div>

<?php
$this->endWidget();
//echo CHtml::endForm();
?>
<div>
    <button class="btn" onclick="javascript:savePriceConfig()"><?php echo '保存配置信息' ?></button>
    <?php
    echo $control->getAjaxLink(array(
        'name' => '更新订单数据',
        'id' => 'buildOrderData'), array(
        'htmlOptions' => array('class' => 'btn'),
        'orderConfigId' => $configId,
        'eventId' => $eventId
            )
    );
    if ($control->isAjaxLinkClicked('buildOrderData')) {
        echo ' build order data completed!';
    }
    ?>
</div>